<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="resources/link-highlight-style.css">
<script src="resources/link-highlight-helper.js"></script>
</head>
<body onload="runTest();">
<div style="will-change: transform; position: relative; left: 10px; top: 10px"></div>
<div id="targetDiv" style="position: relative; left: 10px; top: 40px; width: 200px; height: 100px; overflow-y: scroll; overflow-x: scroll;">
<div id="divToForceCompositedLayer">
<a href="">AAAAAA</a><br>
<a href="">AAAAAA</a><br>
<a href="">AAAAAA</a><br>
<a class="opaqueHighlight" href="" id="targetLink">Target Link.</a><br>
<a href="">AAAAAA</a><br>
<a href="">AAAAAA</a><br>
</div></div>
<div style="position: relative; left: 10px; top: 80px">
This test is successful if "Target Link" above is covered in a green rectangle with square corners.
</div>
<script src="../../resources/run-after-layout-and-paint.js"></script>
<script>
function runTest() {
    useMockHighlight();
    var targetDiv = document.getElementById('targetDiv');
    var clientRect = document.getElementById('targetLink').getBoundingClientRect();
    x = (clientRect.left + clientRect.right) / 2;
    y = (clientRect.top + clientRect.bottom) / 2;
    if (window.testRunner)
        testRunner.waitUntilDone();

    // This test highlights a link in a non-composited overflow-div, then forces that div to become composited,
    // then scrolls that div, then exits. If everything is working correctly, the link highlight will still
    // be displayed correctly after all these operations.
    if (window.eventSender && window.testRunner) {
        eventSender.gestureShowPress(x, y);
        runAfterLayoutAndPaint(function() {
            document.getElementById('divToForceCompositedLayer').style.willChange = 'transform';
            document.body.offsetTop;
            runAfterLayoutAndPaint(function() {
                targetDiv.scrollTop += 20;
                testRunner.notifyDone();
            });
        });
    } else {
        debug("This test requires DumpRenderTree.");
    }
}
</script>
</body>
</html>
